package com.tledu.oop3;

public class OOP07 {
    public static void main(String[] args) {
        // 一旦是一个大学生了，一定是一个学生
        Student student = new CollegeStudents();
        student.setName("张三");
//        student.practice();

        // 如果我们是一个学生，是不是不一定是大学生

        // 如果我们确定它就是大学生，我们可以数据类型一样进行强转
//        CollegeStudents collegeStudents = (CollegeStudents) student;
//        collegeStudents.practice();
//        MiddleSchoolStudent middleSchoolStudent = (MiddleSchoolStudent) student;
//        middleSchoolStudent.setMember("共青团员");
        System.out.println(student instanceof MiddleSchoolStudent);
        // instanceof判断类型是否一致
        if (student instanceof CollegeStudents) {
            CollegeStudents collegeStudents = (CollegeStudents) student;
        }

    }
}
